import { defineNuxtPlugin } from '#app'
import { usePinia } from '#imports'
import {createPersistedState } from 'pinia-plugin-persistedstate'

export default defineNuxtPlugin((nuxtApp) => {
  const pinia = usePinia()
  
  pinia.use(createPersistedState({
    storage: import.meta.client ? localStorage : undefined,
    serializer: {
      serialize: JSON.stringify,
      deserialize: JSON.parse
    },
    auto:true
  }))
})
